﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using Pro.Common.IoC;

namespace Pro.Web
{
    public class MvcDependencyResolver : IDependencyResolver
    {
        private readonly IEngine _componentContainer;

        public MvcDependencyResolver(IEngine componentContainer)
        {
            _componentContainer = componentContainer;
        }

        public object GetService(Type serviceType)
        {
            object instance;
            _componentContainer.TryResolve(serviceType, out instance);
            return instance;
        }

        public IEnumerable<object> GetServices(Type serviceType)
        {
            IEnumerable<object> instance;
            _componentContainer.TryResolve(serviceType, out instance);
            return instance;
        }
    }
}